package com.ruoyi.web.controller.teacher;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.BasisTaskPlanning;
import com.ruoyi.service.IBasisTaskPlanningService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 指挥员任务筹划Controller
 * 
 * @author wangzebing
 * @date 2025-07-12
 */
@RestController
@RequestMapping("/system/planningZH")
public class BasisTaskPlanningController extends BaseController
{
    @Autowired
    private IBasisTaskPlanningService basisTaskPlanningService;

    /**
     * 查询指挥员任务筹划列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasisTaskPlanning basisTaskPlanning)
    {
        startPage();
        List<BasisTaskPlanning> list = basisTaskPlanningService.selectBasisTaskPlanningList(basisTaskPlanning);
        return getDataTable(list);
    }

    /**
     * 导出指挥员任务筹划列表
     */
    @Log(title = "指挥员任务筹划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasisTaskPlanning basisTaskPlanning)
    {
        List<BasisTaskPlanning> list = basisTaskPlanningService.selectBasisTaskPlanningList(basisTaskPlanning);
        ExcelUtil<BasisTaskPlanning> util = new ExcelUtil<BasisTaskPlanning>(BasisTaskPlanning.class);
        util.exportExcel(response, list, "指挥员任务筹划数据");
    }

    /**
     * 获取指挥员任务筹划详细信息
     */
    @GetMapping(value = "/{loadingId}")
    public AjaxResult getInfo(@PathVariable("loadingId") String loadingId)
    {
        return success(basisTaskPlanningService.selectBasisTaskPlanningByLoadingId(loadingId));
    }

    /**
     * 新增指挥员任务筹划
     */
    @Log(title = "指挥员任务筹划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisTaskPlanning basisTaskPlanning)
    {
        return toAjax(basisTaskPlanningService.insertBasisTaskPlanning(basisTaskPlanning));
    }

    /**
     * 修改指挥员任务筹划
     */
    @Log(title = "指挥员任务筹划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisTaskPlanning basisTaskPlanning)
    {
        basisTaskPlanning.setUserId(getUserId());
        return toAjax(basisTaskPlanningService.updateBasisTaskPlanning(basisTaskPlanning));
    }

    /**
     * 删除指挥员任务筹划
     */
    @Log(title = "指挥员任务筹划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{loadingIds}")
    public AjaxResult remove(@PathVariable String[] loadingIds)
    {
        return toAjax(basisTaskPlanningService.deleteBasisTaskPlanningByLoadingIds(loadingIds));
    }

    @GetMapping(value = "/selectBasisTaskPlanningByLoadingIdAndUserId")
    public AjaxResult selectBasisTaskPlanningByLoadingIdAndUserId(String loadingId,Integer userId)
    {
        return success(basisTaskPlanningService.selectBasisTaskPlanningByLoadingIdAndUserId(loadingId,userId));
    }


    @GetMapping(value = "/qxGl1")
    public AjaxResult qxGl1(String loadingId,String resourceId,Long userId)
    {
        return success(basisTaskPlanningService.qxGl1(loadingId,resourceId,userId));
    }





}
